<template>
  <router-view />
</template>
<script>
export default {
  name: "ParentView",
  created() {
    // 如果当前路由有子路由，自动跳转到第一个子路由
    const children =
      this.$route.matched &&
      this.$route.matched[0] &&
      this.$route.matched[0].children;
    if (children && children.length > 0) {
      const firstChild = children[0];
      if (this.$route.path === this.$route.matched[0].path) {
        this.$router.replace({ path: firstChild.path });
      }
    }
  },
};
</script>
